<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/view/conf/farmtag.tld" prefix="PF"%>
<%@ taglib uri="/view/conf/farmdoc.tld" prefix="DOC"%>
<!-- 如果是内容类型等于4小组首页，则在此处不提供任何操作功能 -->
<style>
<!--
.hidden {
	display: none;
}
-->
</style>
<div style="padding: 2px;">
	<c:if test="${fqa.qanswer!=null }">
		<span class="label label-success">已解决</span>
	</c:if>
	<c:if test="${USEROBJ!=null}">
		<button type="button" id="disEnjoyId"
			class="btn btn-default  btn-xs
					<c:if test="${!ISENJOY}">
					hidden
					</c:if>
					">
			<span class="glyphicon glyphicon-star"></span>&nbsp;取消关注
		</button>


		<button type="button" id="enjoyId"
			class="btn btn-default  btn-xs
				<c:if test="${ISENJOY}">
				hidden
				</c:if>
				">
			<span class="glyphicon glyphicon-star"></span>&nbsp;关注
		</button>
		<c:if test="${USEROBJ.id==fqa.question.cuser}">
			<button type="button" id="closelyButtonId"
				class="btn btn-default  btn-xs">
				<span class="glyphicon glyphicon-question-sign"></span>&nbsp;追问
			</button>
		</c:if>
		<!-- <button type="button" id="editTopButtonId"
			class="btn btn-default  btn-xs">
			<span class="glyphicon glyphicon-edit"></span>&nbsp;修改
		</button>
		<button type="button" id="delTopButtonId"
			class="btn btn-default  btn-xs">
			<span class="glyphicon glyphicon-envelope"></span>&nbsp;删除
		</button> -->
	</c:if>
	<c:if test="${USEROBJ==null}">
		<button type="button" class="btn btn-default btn-xs"
			disabled="disabled">
			<span class="glyphicon glyphicon-star"></span>&nbsp;登录后关注
		</button>
	</c:if>
	<h4 class="pull-right">
		&nbsp; <span class="label label-default" title="访问量"><span
			class="glyphicon glyphicon-hand-up"></span>&nbsp;${fqa.question.visitnum}</span>
	</h4>
	<h4 class="pull-right">
		&nbsp; <span class="label label-info" title="回答量"><span
			class="glyphicon glyphicon-comment"></span>&nbsp;${fqa.question.answers}</span>
	</h4>
</div>
<script type="text/javascript">
	$(function() {
		$('#editTopButtonId').bind(
				'click',
				function() {
					window.location = basePath
							+ 'webquest/edit.do?questionid=${fqa.question.id}';
				});
		$('#closelyButtonId')
				.bind(
						'click',
						function() {
							window.location = basePath
									+ 'webquest/closely.do?questionid=${fqa.question.id}';
						});
		$('#delTopButtonId')
				.bind(
						'click',
						function() {
							if (confirm("删除后该问答将无法恢复，确定要删除吗？")) {
								window.location = basePath
										+ 'webquest/FLDelKnow.do?id=${fqa.question.id}';
							}
						});
		//关注
		$('#enjoyId').on('click', function() {
			$.post('webdoc/enjoy.do?id=${DOCE.doc.id}', function(flag) {
				if (flag.commitType == '0') {
					alert('关注成功');
					// 													var buttonStr = '<button type="button" id="disEnjoyId" class="btn btn-default  btn-xs"><span class="glyphicon glyphicon-star"></span>取消关注</button>';
					// 													$('#enjoyId').before(
					// 															buttonStr);
					$('#enjoyId').addClass('hidden');
					$('#disEnjoyId').removeClass('hidden');
				} else {
					alert('关注失败');
				}
			}, 'json');
		});
		//取消关注
		$('#disEnjoyId').on('click', function() {
			$.post('webdoc/FLunEnjoy.do?id=${DOCE.doc.id}', function(flag) {
				if (flag.commitType == '0') {
					alert('取消关注成功');
					// 													var buttonStr = '<button type="button" id="enjoyId" class="btn btn-default  btn-xs"><span class="glyphicon glyphicon-star"></span>关注</button>';
					// 													$('#disEnjoyId').before(
					// 															buttonStr);
					// 													$('#disEnjoyId').remove();
					$('#enjoyId').removeClass('hidden');
					$('#disEnjoyId').addClass('hidden');
				} else {
					alert('取消关注失败');
				}
			}, 'json');
		});
	});
</script>